//#include <iostream>
//#include <vector>
//#include <fstream>
//#include <exception>
//#include <stdexcept>
//#include <sstream>
//#include <string>
//using namespace std;
//
//class MyException : public exception, public nested_exception
//{public:
//	MyException(const char* msg): mMsg(msg){}
//	virtual ~MyException() noexcept{}
//	virtual const char* what() const noexcept{ return mMsg.c_str(); }
//protected:
//	string mMsg;
//};
//
//void doSomething()
//{
//	try {
//		throw runtime_error("Throwing a runtime_error exception");
//	}
//	catch ( const runtime_error& e) {
//		cout << __func__ << " caught a runtime_error" << endl;
//		cout << __func__ << " throwing MyException " << endl;
//		throw_with_nested(
//		MyException("MyException with nested runtime_error"));
//	}
//}
//
//int main()
//{
//	try {
//		doSomething();
//	}
//	catch (const MyException& e) {
//		std::cout << __func__ << " caught MyException: " << e.what()
//			<< std::endl;
//		const std::nested_exception* pNested =
//			dynamic_cast<const std::nested_exception*>(&e);
//		if (pNested) {
//			try {
//				pNested->rethrow_nested();
//			}
//			catch (const std::runtime_error& e) {
//				//Handle nesed exception
//				std::cout << " Nested exception: " << e.what()
//					<< std::endl;
//			}
//		}
//	}
//
//	return 0;
//}